package com.pairuan.front.controller;

import com.pairuan.common.domain.AjaxResult;
import com.pairuan.service.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录控制器
 */
@Tag(name = "登录管理")
@RestController
@RequiredArgsConstructor
public class LoginController {

    private final UserService userService;

    /**
     * 用户登录
     */
    @Operation(summary = "用户登录")
    @PostMapping("/login")
    public AjaxResult login(@RequestParam String username, @RequestParam String password) {
        Long userId = userService.login(username, password);
        return AjaxResult.success(userId);
    }
} 